package com.itheima.springboot_14_test.controller;

import com.itheima.springboot_14_test.domain.Book;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;



@RestController //这是一个restful风格的控制器 注释掉,就不会被spring监管到了 == @Controller+@ResponseBody //表示这个类的方法都有返回值
@RequestMapping("/books") //访问/books就能访问到这个类 (value = "/users",method = RequestMethod.POST) //定义url和访问方法为post
public class BookController {

    @GetMapping
    public String getById(){
        System.out.println("getById is running");
        return "getById is running";
    }
    @GetMapping("{id}")
    public Book getById2(){
        Book book=new Book();
        book.setId(1);
        book.setDescription("曹雪芹");
        book.setName("红楼梦");
        book.setType("纸质版");
        return book;
    }

}

